﻿using AutoMapper;
using System;
using System.Collections.Generic;

namespace JiaBao.Core.Infrastructure.Mapper
{
    public class AutoMapperConfiguration
    {
        private static MapperConfiguration _mapperConfiguration;
        private static IMapper _mapper;


        #region 属性

        public static IMapper Mapper { get { return _mapper; } }

        public static MapperConfiguration MapperConfiguration { get { return _mapperConfiguration; } }

        #endregion

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="configurationActions"></param>
        public static void Init(List<Action<IMapperConfigurationExpression>> configurationActions)
        {
            if (configurationActions == null)
                throw new ArgumentNullException("configurationActions");

            _mapperConfiguration = new MapperConfiguration(cfg =>
            {
                foreach (var ca in configurationActions)
                    ca(cfg);
            });
        }



    }
}
